//
//  UIScrollViewDemo.swift
//  firstProject
//
//  Created by 张彦辉 on 2017/4/3.
//  Copyright © 2017年 张彦辉. All rights reserved.
//

import UIKit

class UIScrollViewDemo: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.gray
        let scroll:UIScrollView = UIScrollView(frame: self.view.frame)
        //创建一个view
        let view:UIView = UIView(frame: CGRect(x: self.view.frame.size.width-100, y: 100, width: 100, height: 100))
        view.backgroundColor = UIColor.red
        scroll.addSubview(view)
        //创建第二个view
        let view2:UIView = UIView(frame: CGRect(x: self.view.frame.size.width*2-100, y: 100, width: 100, height: 100))
        view2.backgroundColor = UIColor.green
        scroll.addSubview(view2)
        //设置scrollView的内容尺寸
        scroll.contentSize = CGSize(width: self.view.frame.size.width*2, height: self.view.frame.size.height)
        //设置回弹效果
        scroll.bounces = false
        //设置水平滚动条不显示
        scroll.showsHorizontalScrollIndicator = false
        //设置垂直滚动条不显示
        scroll.showsVerticalScrollIndicator = false
        //设置是否翻页效果
        scroll.isPagingEnabled = true
        self.view.addSubview(scroll)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
